/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author amega
 */
@Entity
@Table(name = "orders")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Orders.findAll", query = "SELECT o FROM Orders o"),
    @NamedQuery(name = "Orders.findById", query = "SELECT o FROM Orders o WHERE o.id = :id"),
    @NamedQuery(name = "Orders.findByIsPaid", query = "SELECT o FROM Orders o WHERE o.isPaid = :isPaid"),
    @NamedQuery(name = "Orders.findByTotalCost", query = "SELECT o FROM Orders o WHERE o.totalCost = :totalCost"),
    @NamedQuery(name = "Orders.findByPrepay", query = "SELECT o FROM Orders o WHERE o.prepay = :prepay"),
    @NamedQuery(name = "Orders.findByDateOrder", query = "SELECT o FROM Orders o WHERE o.dateOrder = :dateOrder")})
public class Orders implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "isPaid")
    private boolean isPaid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "totalCost")
    private double totalCost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "prepay")
    private double prepay;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateOrder")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOrder;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOrder")
    private List<OrderProduct> orderProductList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOrder")
    private List<OrderRoom> orderRoomList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idOrder")
    private List<OrderHall> orderHallList;
    @JoinColumn(name = "idUser", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Users idUser;

    public Orders() {
    }

    public Orders(Integer id) {
        this.id = id;
    }

    public Orders(Integer id, boolean isPaid, double totalCost, double prepay, Date dateOrder) {
        this.id = id;
        this.isPaid = isPaid;
        this.totalCost = totalCost;
        this.prepay = prepay;
        this.dateOrder = dateOrder;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public boolean getIsPaid() {
        return isPaid;
    }

    public void setIsPaid(boolean isPaid) {
        this.isPaid = isPaid;
    }

    public double getTotalCost() {
        return totalCost;
    }

    public void setTotalCost(double totalCost) {
        this.totalCost = totalCost;
    }

    public double getPrepay() {
        return prepay;
    }

    public void setPrepay(double prepay) {
        this.prepay = prepay;
    }

    public Date getDateOrder() {
        return dateOrder;
    }

    public void setDateOrder(Date dateOrder) {
        this.dateOrder = dateOrder;
    }

    @XmlTransient
    public List<OrderProduct> getOrderProductList() {
        return orderProductList;
    }

    public void setOrderProductList(List<OrderProduct> orderProductList) {
        this.orderProductList = orderProductList;
    }

    @XmlTransient
    public List<OrderRoom> getOrderRoomList() {
        return orderRoomList;
    }

    public void setOrderRoomList(List<OrderRoom> orderRoomList) {
        this.orderRoomList = orderRoomList;
    }

    @XmlTransient
    public List<OrderHall> getOrderHallList() {
        return orderHallList;
    }

    public void setOrderHallList(List<OrderHall> orderHallList) {
        this.orderHallList = orderHallList;
    }

    public Users getIdUser() {
        return idUser;
    }

    public void setIdUser(Users idUser) {
        this.idUser = idUser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orders)) {
            return false;
        }
        Orders other = (Orders) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "domain.Orders[ id=" + id + " ]";
    }
    
}
